package com.xiaoshuidi.cloud.module.contract.enums.contract;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum ContractApproveTypeEnum {


    CONTRACT_NEW(ContractNodeEnum.NEW.getCode(), "contract_new","合同新签审批"),
    CONTRACT_RENEWAL(ContractNodeEnum.RENEWAL.getCode(), "contract_renewal","合同续约审批"),
    CONTRACT_RENTING_OUT(ContractNodeEnum.RENTING_OUT.getCode(), "contract_renting_out","合同退租审批"),
    CONTRACT_EXCHANGE(ContractNodeEnum.EXCHANGE.getCode(), "contract_exchange","合同换房待审批"),

    ;
//    //类型
//    private final String type;
    //编码
    private final String code;
    //业务编码
    private final String businessKey;
    //信息
    private final String msg;

    private static final Map<String, ContractApproveTypeEnum> enumMap = new HashMap<>();

    static {
        ContractApproveTypeEnum[] values = ContractApproveTypeEnum.values();
        for (ContractApproveTypeEnum value : values) {
            enumMap.put(value.getCode(), value);
        }
    }

    public static ContractApproveTypeEnum getEnum(String num) {
        return enumMap.get(num);
    }

    public static String getBillTypeEnumByCode(String code) {
        ContractApproveTypeEnum[] ContractApproveTypeEnum = values();
        for (ContractApproveTypeEnum contractApproveTypeEnum : ContractApproveTypeEnum) {
            if (contractApproveTypeEnum.code.equals(code)) {
                return contractApproveTypeEnum.code;
            }
        }
        return null;
    }
}
